package main

import (
	"fmt"
	"sync"
)

// START OMIT
type Foo struct {
	sync.Mutex
}

func main() {
	foo := &Foo{}
	foo.Lock()
	foo.Unlock()
	safeDo(foo, func() {
		foo.Unsafe()
	})
}

type Locker interface {
	Lock()
	Unlock()
}

func safeDo(l Locker, f func()) {
	l.Lock()
	defer l.Unlock()
	f()
}

// STOP OMIT

func (f *Foo) Unsafe() {
	fmt.Println("unsafe")
}
